package com.atguigu.spzx.manner.service.impl;

import com.atguigu.spzx.manner.mapper.SysMenuMapper;
import com.atguigu.spzx.manner.mapper.SysRoleMenumapper;
import com.atguigu.spzx.manner.service.SysMenuService;
import com.atguigu.spzx.manner.service.SysRoleMenuService;
import com.atguigu.spzx.model.entity.AssignMenuDto;
import com.atguigu.spzx.model.entity.SysMenu;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SysRoleMenuServiceImpl implements SysRoleMenuService {
    @Autowired
    SysMenuMapper sysMenuMapper;
    @Autowired
    SysRoleMenumapper sysRoleMenumapper;
    @Autowired
    SysMenuService sysMenuService;
    @Override
    public List<SysMenu> findSysRoleMenu() {
        List<SysMenu> nodes = sysMenuService.findNodes();
        return nodes;
    }

    @Override
    public List<Long> findSysRoleMenuByRoleId(Long id) {
        List<Long> sysMenuList = sysMenuMapper.selectSysMenu(id);
        return sysMenuList;
    }

    @Override
    public void doAssign(AssignMenuDto assignMenuDto) {
        //先删除
        sysRoleMenumapper.deleteSysMenu(assignMenuDto.getRoleId());
        //后添加
        sysRoleMenumapper.insertSysMenu(assignMenuDto);

    }
}
